import request from '@/utils/request'

export function menus() {
  return request({
    url: '/menus',
    method: 'get'
  })
}

// 获取角色列表
export function tableRoles() {
  return request({
    url: '/roles',
    method: 'get'
  })
}

// 添加用户
export function tableAdd(data) {
  console.log(data)
  return request({
    url: 'roles',
    method: 'POST',
    data
  })
}

// 编辑提交角色
export function tableEditor(id, data) {
  return request({
    url: `roles/${id}`,
    method: 'put',
    data
  })
}

// 权限列表
export function tableTree(type) {
  return request({
    url: `rights/${type}`,
    method: 'get'
  })
}

// 数节点权限分配接口
export function tableRids(id, data) {
  return request({
    url: `/roles/${id}/rights`,
    method: 'POST',
    data
  })
}

// tag 标签删除
export function removeTag(rowId, tagId) {
  return request({
    url: `roles/${rowId}/rights/${tagId}`,
    method: 'delete'
  })
}

// 删除角色
export function removeRow(id) {
  return request({
    url: `roles/${id}`,
    method: 'DELETE'
  })
}
